home *** CD-ROM | disk | FTP | other *** search
/ PC Plus SuperCD (UK) 1998 August / PC Plus SuperCD 50b Issue 142 (CD142b) (August 1998).iso / handson / Java / sc20form.jar / com / supercede / forms / SuperCedeDialog.class (.txt) < prev    next >
Encoding:
Java Class File  |  1998-01-28  |  6.2 KB  |  265 lines

  1. package com.supercede.forms;
  2.  
  3. import java.applet.Applet;
  4. import java.awt.AWTEvent;
  5. import java.awt.Component;
  6. import java.awt.Container;
  7. import java.awt.Dialog;
  8. import java.awt.Frame;
  9. import java.awt.Graphics;
  10. import java.awt.Point;
  11. import java.awt.event.WindowEvent;
  12. import java.io.IOException;
  13. import java.io.InvalidObjectException;
  14. import java.io.ObjectInputStream;
  15. import java.io.Serializable;
  16. import java.util.Vector;
  17.  
  18. public class SuperCedeDialog extends Dialog implements SuperCedeDesignContainer, Serializable {
  19.    SuperCedeRuntimeInfo runtimeInfo;
  20.    SuperCedeDesignInfo designInfo;
  21.    transient boolean designMode;
  22.    transient DesignModeListener formListener;
  23.    transient Vector scContainerListeners;
  24.    boolean shadowEnabled;
  25.    boolean shadowModal;
  26.    Point shadowLocation;
  27.    private static final long serialVersionUID = 1013082004010516611L;
  28.    private static final int _version = 1;
  29.    private int version;
  30.  
  31.    public SuperCedeDialog() {
  32.       this(new Frame());
  33.    }
  34.  
  35.    public SuperCedeDialog(Frame var1) {
  36.       super(var1);
  37.       this.version = 1;
  38.       this.runtimeInfo = new SuperCedeRuntimeInfo();
  39.       this.designInfo = new SuperCedeDesignInfo();
  40.       this.designMode = false;
  41.       this.formListener = null;
  42.       this.scContainerListeners = null;
  43.       this.shadowEnabled = super.isEnabled();
  44.       this.shadowModal = super.isModal();
  45.       this.shadowLocation = new Point(0, 0);
  46.    }
  47.  
  48.    public final void initializeThis(Vector var1) throws IOException, ClassNotFoundException, ClassCastException, SuperCedeInvalidStateException {
  49.       this.designInfo = null;
  50.       this.runtimeInfo = null;
  51.       SuperCedeHelper.runTimeConstructor(this, var1);
  52.       this.setModal(this.shadowModal);
  53.       ((Component)this).setLocation(this.shadowLocation);
  54.       ((Component)this).enableEvents(64L);
  55.       this.validateObject();
  56.    }
  57.  
  58.    public Component[] getContainedComponents() {
  59.       return ((Container)this).getComponents();
  60.    }
  61.  
  62.    public void initializeFrom(SuperCedeContainer var1) throws ClassCastException, SuperCedeInvalidStateException {
  63.       try {
  64.          this.setDesignMode(((SuperCedeDesignContainer)var1).isDesignMode());
  65.          this.setFormListener(((SuperCedeDesignContainer)var1).getFormListener());
  66.          this.runtimeInfo = var1.getRuntimeInfo();
  67.          this.designInfo = ((SuperCedeDesignContainer)var1).getDesignInfo();
  68.          SuperCedeHelper.convertContainer((Container)var1, this);
  69.          if (!this.isDesignMode()) {
  70.             this.runtimeInfo = null;
  71.             this.designInfo = null;
  72.          }
  73.       } catch (ClassCastException var3) {
  74.          throw var3;
  75.       }
  76.    }
  77.  
  78.    public SuperCedeDesignInfo getDesignInfo() {
  79.       return this.designInfo;
  80.    }
  81.  
  82.    public SuperCedeRuntimeInfo getRuntimeInfo() {
  83.       return this.runtimeInfo;
  84.    }
  85.  
  86.    public void addComponent(Component var1, Object var2) {
  87.       this.addComponent(var1, var2, -1);
  88.    }
  89.  
  90.    public void addComponent(Component var1, Object var2, int var3) {
  91.       this.add(var1, var2, var3);
  92.       this.runtimeInfo.addLayoutConstraints(var1, var2);
  93.    }
  94.  
  95.    public void add(Component var1, Object var2, int var3) {
  96.       super.add(var1, var2, var3);
  97.       if (((Component)this).isVisible() && var1 instanceof Applet) {
  98.          ((Applet)var1).start();
  99.       }
  100.  
  101.    }
  102.  
  103.    public void removeComponent(int var1) {
  104.       this.removeComponent(((Container)this).getComponent(var1));
  105.    }
  106.  
  107.    public void removeComponent(Component var1) {
  108.       this.runtimeInfo.removeLayoutConstraints(var1);
  109.       this.remove(var1);
  110.    }
  111.  
  112.    public void remove(Component var1) {
  113.       if (((Component)this).isVisible() && var1 instanceof Applet) {
  114.          ((Applet)var1).stop();
  115.       }
  116.  
  117.       super.remove(var1);
  118.    }
  119.  
  120.    public boolean isEnabled() {
  121.       return this.shadowEnabled;
  122.    }
  123.  
  124.    public void setEnabled(boolean var1) {
  125.       this.shadowEnabled = var1;
  126.       if (!this.isDesignMode()) {
  127.          super.setEnabled(var1);
  128.       }
  129.  
  130.    }
  131.  
  132.    public void paint(Graphics var1) {
  133.       if (this.formListener != null) {
  134.          this.formListener.paint(var1);
  135.       }
  136.  
  137.       super.paint(var1);
  138.    }
  139.  
  140.    public void addNotify() {
  141.       super.addNotify();
  142.       if (this.formListener != null) {
  143.          this.formListener.addedPeer();
  144.       }
  145.  
  146.    }
  147.  
  148.    public void removeNotify() {
  149.       if (this.formListener != null) {
  150.          this.formListener.removingPeer();
  151.       }
  152.  
  153.       super.removeNotify();
  154.    }
  155.  
  156.    public boolean isModal() {
  157.       return this.isDesignMode() ? this.shadowModal : super.isModal();
  158.    }
  159.  
  160.    public void setModal(boolean var1) {
  161.       this.shadowModal = var1;
  162.       if (!this.isDesignMode()) {
  163.          super.setModal(var1);
  164.       }
  165.  
  166.    }
  167.  
  168.    public Object getLayoutConstraints(Component var1) {
  169.       return this.runtimeInfo.getLayoutConstraints(var1);
  170.    }
  171.  
  172.    public Object getLayoutConstraints(int var1) {
  173.       return this.getLayoutConstraints(((Container)this).getComponent(var1));
  174.    }
  175.  
  176.    public void setDesignMode(boolean var1) {
  177.       this.designMode = var1;
  178.    }
  179.  
  180.    public boolean isDesignMode() {
  181.       return this.designMode;
  182.    }
  183.  
  184.    public void setFormListener(DesignModeListener var1) {
  185.       this.formListener = var1;
  186.    }
  187.  
  188.    public DesignModeListener getFormListener() {
  189.       return this.formListener;
  190.    }
  191.  
  192.    public void setVisible(boolean var1) {
  193.       if (!var1) {
  194.          SuperCedeHelper.setAppletVisibility(this, this.isDesignMode(), false);
  195.       }
  196.  
  197.       boolean var2 = this.isDesignMode();
  198.       this.setDesignMode(false);
  199.       super.setVisible(var1);
  200.       this.setDesignMode(var2);
  201.       if (var1) {
  202.          SuperCedeHelper.setAppletVisibility(this, this.isDesignMode(), true);
  203.       }
  204.  
  205.    }
  206.  
  207.    protected void processWindowEvent(WindowEvent var1) {
  208.       if (((AWTEvent)var1).getID() == 201 && this.scContainerListeners != null) {
  209.          SuperCedeContainerEvent var3 = new SuperCedeContainerEvent(this, 4434);
  210.          synchronized(this){}
  211.  
  212.          Vector var2;
  213.          try {
  214.             var2 = (Vector)this.scContainerListeners.clone();
  215.          } catch (Throwable var6) {
  216.             throw var6;
  217.          }
  218.  
  219.          for(int var4 = 0; var4 < var2.size(); ++var4) {
  220.             ((SuperCedeContainerListener)var2.elementAt(var4)).containerShutdown(var3);
  221.          }
  222.       }
  223.  
  224.       super.processWindowEvent(var1);
  225.    }
  226.  
  227.    public void addSuperCedeContainerListener(SuperCedeContainerListener var1) {
  228.       synchronized(this){}
  229.  
  230.       try {
  231.          if (this.scContainerListeners == null) {
  232.             this.scContainerListeners = new Vector();
  233.          }
  234.  
  235.          this.scContainerListeners.addElement(var1);
  236.       } catch (Throwable var4) {
  237.          throw var4;
  238.       }
  239.  
  240.    }
  241.  
  242.    public void removeSuperCedeContainerListener(SuperCedeContainerListener var1) {
  243.       synchronized(this){}
  244.  
  245.       try {
  246.          this.scContainerListeners.removeElement(var1);
  247.       } catch (Throwable var4) {
  248.          throw var4;
  249.       }
  250.  
  251.    }
  252.  
  253.    private void readObject(ObjectInputStream var1) throws IOException, ClassNotFoundException {
  254.       var1.defaultReadObject();
  255.  
  256.       try {
  257.          SuperCedeHelper.doDeserializationProcessing(this);
  258.       } catch (SuperCedeInvalidStateException var2) {
  259.       }
  260.    }
  261.  
  262.    public void validateObject() throws InvalidObjectException {
  263.    }
  264. }
  265.